/*
 * GUIInit.cpp
 *
 *  Created on: 01.12.2011
 *      Author: Andrey Efimov
 *      Copyright: LGPL
 */

#include "GUIInit.h"

//--------------------------------------------------------------------------------
CNodeTree::CNodeTree()
{
	parent = NULL;
	children = NULL;
	next = NULL;
	prev = NULL;
}
//--------------------------------------------------------------------------------
CTreeIterator::CTreeIterator()
{
	first = NULL;
	current = NULL;
}
//--------------------------------------------------------------------------------
CTreeIterator::CTreeIterator(CNodeTree* f)
{
	first = f;
	current = f;
}
//--------------------------------------------------------------------------------
CNodeTree* CTreeIterator::First()
{
	return first;
}
//--------------------------------------------------------------------------------
CNodeTree* CTreeIterator::Next()
{
	if (current->children != NULL)	//���� ���� ����
		return current = current->children;
	else
	{
		if (current->next != NULL)	//���� ���� ����. ����. � ������
			return current = current->next;
		else	//���� ��� ����. ����.
		{
			while (true)
			{
				if (current->parent != NULL)	//��������� � ��������, ���� �� ����
				{
					current = current->parent;
					if (current->next != NULL)	//� � ����.����., ���� �� ����
						return current = current->next;
				}
				else	//���� ��� ��������, ������� ��������
					break;
			}
		}
	}
	return NULL;
}
//--------------------------------------------------------------------------------
CNodeTree* CTreeIterator::NextXY(glm::vec2 MouseXY)
{
	while (true)
	{
		if ((current->data->GetPosition().x) < MouseXY.x && (current->data->GetPosition().y < MouseXY.y) &&
			((current->data->GetPosition().x + current->data->GetSize().x) > MouseXY.x) &&
			((current->data->GetPosition().y + current->data->GetSize().y) > MouseXY.y))
		{
			if (current->children != NULL)
				current = current->children;
			else
				return current;
		}
		else
		{
			if (current->next != NULL)
				current = current->next;
			else
			{
				if (current->parent != NULL)
				{
					current = current->parent;
					if ((current->data->GetPosition().x < MouseXY.x) && (current->data->GetPosition().y < MouseXY.y) &&
						((current->data->GetPosition().x + current->data->GetSize().x) > MouseXY.x) &&
						((current->data->GetPosition().y + current->data->GetSize().y) > MouseXY.y))
						return current;
					else
						return NULL;
				}
				else
					return NULL;
			}
		}
	}
	return NULL;
}
//--------------------------------------------------------------------------------
bool CTreeIterator::CheckCollision(CGuiBase* data)
{
	CNodeTree* NodeTemp = NULL;
	if (first == NULL)
		return true;
	if (current == NULL)
		NodeTemp = first;
	else if (current->children != NULL)
		NodeTemp = current->children;
	if (NodeTemp != NULL)
	{
		while (true)
		{
			if (((data->GetPosition().x + data->GetSize().x) < NodeTemp->data->GetPosition().x) ||
				(data->GetPosition().x > (NodeTemp->data->GetPosition().x + NodeTemp->data->GetSize().x)) ||
				((data->GetPosition().y + data->GetSize().y) < NodeTemp->data->GetPosition().y) ||
				(data->GetPosition().y > (NodeTemp->data->GetPosition().y + NodeTemp->data->GetSize().y)))
			{
				if (NodeTemp->next != NULL)
					NodeTemp = NodeTemp->next;
				else
					break;
			}
			else
				return false;
		}
	}

	if (current != NULL)
	{
		if ((data->GetPosition().x > current->data->GetPosition().x) &&
			(data->GetPosition().y > current->data->GetPosition().y) &&
			((data->GetPosition().x + data->GetSize().x) < (current->data->GetPosition().x + current->data->GetSize().x)) &&
			((data->GetPosition().y + data->GetSize().y) < (current->data->GetPosition().y + current->data->GetSize().y)))
			return true;
		else
			return false;
	}
	return true;
}
//--------------------------------------------------------------------------------
bool CTreeIterator::AddNode(CGuiBase* data)
{
	CNodeTree* temp = new CNodeTree;
	temp->data = data;
	temp->children = NULL;
	temp->next = NULL;
	temp->prev = NULL;

	if (first == NULL)
	{
		first = temp;
		temp->parent = NULL;
	}
	else
		if (current == NULL)
		{
			temp->parent = NULL;
			CNodeTree* temp2;
			temp2 = first;
			while (true)
			{
				if (temp2->next != NULL)
					temp2 = temp2->next;
				else
				{
					temp2->next = temp;
					temp->prev = temp2;
					break;
				}
			}
		}
	else
	{
		temp->parent = current;
		if (current->children != NULL)
		{
			CNodeTree* temp2;
			temp2 = current->children;
			while (true)
			{
				if (temp2->next != NULL)
					temp2 = temp2->next;
				else
				{
					temp2->next = temp;
					temp->prev = temp2;
					break;
				}
			}
		}
		else
			current->children = temp;
	}
	current = temp;
	return true;
}
//--------------------------------------------------------------------------------
bool CTreeIterator::DelNode(CNodeTree* node, bool flag)
{
	if (flag == true)
	{
		if (node->parent != NULL)
		{
			if (node->prev != NULL)
			{
				if (node->next != NULL)
					node->prev->next = node->next;
				else
					node->prev->next = NULL;
			}
			else
			{
				if (node->next != NULL)
					node->parent->children = node->next;
				else
					node->parent->children = NULL;
			}
		}
		else
			if (node->prev != NULL)
			{
				if (node->next != NULL)
					node->prev->next = node->next;
				else
					node->prev->next = NULL;
			}
			else
			{
				if (node->next != NULL)
					first = node->next;
			}

	}
	CNodeTree* temp = Next();
	if (temp != NULL)
		DelNode(temp,false);
	delete node;
	return true;
}
//--------------------------------------------------------------------------------
COwnerIterator::COwnerIterator()
{
	//TreeIterator = new CTreeIterator();
}
//--------------------------------------------------------------------------------
CTreeIterator* COwnerIterator::GetIterator()
{
	CTreeIterator* TI = new CTreeIterator(TreeIterator);
	return TI;
}
//--------------------------------------------------------------------------------
bool COwnerIterator::FreeIterator(CTreeIterator* TI)
{
	delete TI;
	return true;
}
//--------------------------------------------------------------------------------
bool CShablon::GetShablons( const char* FileShablon )
{
	vector<SAllShablon> AllShablon;
	//---����� ������� ��������� �������� �� �������� ��������
	CManagerResource* MResource;
	MResource = new CManagerResource();
	MResource->GetShablon( FileShablon, AllShablon );
	//-------------------
	for(vector<SAllShablon>::const_iterator it = AllShablon.begin(),
			end = AllShablon.end(); it != end; it++)
	{
		const SAllShablon* CurrentShablonType = it.base();

		for(vector<SOneShablon>::const_iterator it2 = CurrentShablonType->OneShablon.begin(),
				end2 = CurrentShablonType->OneShablon.end(); it2 != end2; it2++)
		{
			const SOneShablon* CurrentShablon = it2.base();

			switch( CurrentShablonType->Tip )
			{
				break;case TYPE_LABEL:
				{
					CLabel* Label = new CLabel();
					Label->Size = CurrentShablon->Size;
					Label->Texture1 = CurrentShablon->Texture1;
					Label->Texture2 = CurrentShablon->Texture2;
					Label->Texture3 = CurrentShablon->Texture3;
					Label->Texture4 = CurrentShablon->Texture4;
					Label->Texture5 = CurrentShablon->Texture5;
					ShablonLabel.push_back(Label);
				}
				break;case TYPE_EDIT:
				{
					CEdit* Edit = new CEdit();
					Edit->Size = CurrentShablon->Size;
					Edit->Texture1 = CurrentShablon->Texture1;
					Edit->Texture2 = CurrentShablon->Texture2;
					Edit->Texture3 = CurrentShablon->Texture3;
					Edit->Texture4 = CurrentShablon->Texture4;
					Edit->Texture5 = CurrentShablon->Texture5;
					ShablonEdit.push_back(Edit);
				}
				break;case TYPE_MEMO:
				{
					CMemo* Memo = new CMemo();
					Memo->Size = CurrentShablon->Size;
					Memo->Texture1 = CurrentShablon->Texture1;
					Memo->Texture2 = CurrentShablon->Texture2;
					Memo->Texture3 = CurrentShablon->Texture3;
					Memo->Texture4 = CurrentShablon->Texture4;
					Memo->Texture5 = CurrentShablon->Texture5;
					ShablonMemo.push_back(Memo);
				}
				break;case TYPE_LISTBOX:
				{
					CListBox* ListBox = new CListBox();
					ListBox->Size = CurrentShablon->Size;
					ListBox->Texture1 = CurrentShablon->Texture1;
					ListBox->Texture2 = CurrentShablon->Texture2;
					ListBox->Texture3 = CurrentShablon->Texture3;
					ListBox->Texture4 = CurrentShablon->Texture4;
					ListBox->Texture5 = CurrentShablon->Texture5;
					ShablonListBox.push_back(ListBox);
				}
				break;case TYPE_COMBOBOX:
				{
					CComboBox* ComboBox = new CComboBox();
					ComboBox->Size = CurrentShablon->Size;
					ComboBox->Texture1 = CurrentShablon->Texture1;
					ComboBox->Texture2 = CurrentShablon->Texture2;
					ComboBox->Texture3 = CurrentShablon->Texture3;
					ComboBox->Texture4 = CurrentShablon->Texture4;
					ComboBox->Texture5 = CurrentShablon->Texture5;
					ShablonComboBox.push_back(ComboBox);
				}
				break;case TYPE_BUTTON:
				{
					CButton* Button = new CButton();
					Button->Size = CurrentShablon->Size;
					Button->Texture1 = CurrentShablon->Texture1;
					Button->Texture2 = CurrentShablon->Texture2;
					Button->Texture3 = CurrentShablon->Texture3;
					Button->Texture4 = CurrentShablon->Texture4;
					Button->Texture5 = CurrentShablon->Texture5;
					ShablonButton.push_back(Button);
				}
				break;case TYPE_CHECKBOX:
				{
					CCheckBox* CheckBox = new CCheckBox();
					CheckBox->Size = CurrentShablon->Size;
					CheckBox->Texture1 = CurrentShablon->Texture1;
					CheckBox->Texture2 = CurrentShablon->Texture2;
					CheckBox->Texture3 = CurrentShablon->Texture3;
					CheckBox->Texture4 = CurrentShablon->Texture4;
					CheckBox->Texture5 = CurrentShablon->Texture5;
					ShablonCheckBox.push_back(CheckBox);
				}
				break;case TYPE_RADIOBUTTON:
				{
					CRadioButton* RadioButton = new CRadioButton();
					RadioButton->Size = CurrentShablon->Size;
					RadioButton->Texture1 = CurrentShablon->Texture1;
					RadioButton->Texture2 = CurrentShablon->Texture2;
					RadioButton->Texture3 = CurrentShablon->Texture3;
					RadioButton->Texture4 = CurrentShablon->Texture4;
					RadioButton->Texture5 = CurrentShablon->Texture5;
					ShablonRadioButton.push_back(RadioButton);
				}
				break;case TYPE_PROGRESSBAR:
				{
					CProgressBar* ProgressBar = new CProgressBar();
					ProgressBar->Size = CurrentShablon->Size;
					ProgressBar->Texture1 = CurrentShablon->Texture1;
					ProgressBar->Texture2 = CurrentShablon->Texture2;
					ProgressBar->Texture3 = CurrentShablon->Texture3;
					ProgressBar->Texture4 = CurrentShablon->Texture4;
					ProgressBar->Texture5 = CurrentShablon->Texture5;
					ShablonProgressBar.push_back(ProgressBar);
				}
				break;case TYPE_TRACKBAR:
				{
					CTrackBar* TrackBar = new CTrackBar();
					TrackBar->Size = CurrentShablon->Size;
					TrackBar->Texture1 = CurrentShablon->Texture1;
					TrackBar->Texture2 = CurrentShablon->Texture2;
					TrackBar->Texture3 = CurrentShablon->Texture3;
					TrackBar->Texture4 = CurrentShablon->Texture4;
					TrackBar->Texture5 = CurrentShablon->Texture5;
					ShablonTrackBar.push_back(TrackBar);
				}
				break;case TYPE_PANEL:
				{
					CPanel* Panel = new CPanel();
					Panel->Size = CurrentShablon->Size;
					Panel->Texture1 = CurrentShablon->Texture1;
					Panel->Texture2 = CurrentShablon->Texture2;
					Panel->Texture3 = CurrentShablon->Texture3;
					Panel->Texture4 = CurrentShablon->Texture4;
					Panel->Texture5 = CurrentShablon->Texture5;
					ShablonPanel.push_back(Panel);
				}
				break;case TYPE_INVENTAR:
				{
					CInventar* Inventar = new CInventar();
					Inventar->Size = CurrentShablon->Size;
					Inventar->Texture1 = CurrentShablon->Texture1;
					Inventar->Texture2 = CurrentShablon->Texture2;
					Inventar->Texture3 = CurrentShablon->Texture3;
					Inventar->Texture4 = CurrentShablon->Texture4;
					Inventar->Texture5 = CurrentShablon->Texture5;
					ShablonInventar.push_back(Inventar);
				}
				break;default:
				{
					return false;
				}
			}
		}
	}
	return true;
}
//--------------------------------------------------------------------------------
CManagerGUI::CManagerGUI()
{
	Shablon = new CShablon();
	CurrentFocus = NULL;
	CurrentFocusMouse = NULL;
	OwnerIterator = new COwnerIterator();
	LastPositionList = 0;
}
//--------------------------------------------------------------------------------
bool CManagerGUI::Init( const char* FileShablon, const char* FileControl )
{
	vector<SMapGUI> MapGUI;
	CManagerResource* MResource;
	MResource = new CManagerResource();

	Shablon->GetShablons( FileShablon );
	MResource->GetMapGUI( FileControl, MapGUI );

	for(vector<SMapGUI>::const_iterator it = MapGUI.begin(),
			end = MapGUI.end(); it != end; it++)
	{
		const SMapGUI* CurrentType = it.base();

		for(vector<SOneMapGUI>::const_iterator it2 = CurrentType->OneMapGUI.begin(),
				end2 = CurrentType->OneMapGUI.end(); it2 != end2; it2++)
		{
			const SOneMapGUI* OneCurrent = it2.base();

			switch( CurrentType->Tip )
			{
				break;case TYPE_LABEL:
				{
					CLabel* Label = Shablon->ShablonLabel[OneCurrent->TipShablon];
					Label = new CLabel( *( Label ) );
					Label->SetName( OneCurrent->Name );
					Label->SetPosition( OneCurrent->Position );
					AddControl( OneCurrent->Parent, Label);
				}
				break;case TYPE_EDIT:
				{
					CEdit* Edit = Shablon->ShablonEdit[OneCurrent->TipShablon];
					Edit = new CEdit( *( Edit ) );
					Edit->SetName( OneCurrent->Name );
					Edit->SetPosition( OneCurrent->Position );
					AddControl( OneCurrent->Parent, Edit);
				}
				break;case TYPE_MEMO:
				{
					CMemo* Memo = Shablon->ShablonMemo[OneCurrent->TipShablon];
					Memo = new CMemo( *( Memo ) );
					Memo->SetName( OneCurrent->Name );
					Memo->SetPosition( OneCurrent->Position );
					AddControl( OneCurrent->Parent, Memo);
				}
				break;case TYPE_LISTBOX:
				{
					CListBox* ListBox = Shablon->ShablonListBox[OneCurrent->TipShablon];
					ListBox = new CListBox( *( ListBox ) );
					ListBox->SetName( OneCurrent->Name );
					ListBox->SetPosition( OneCurrent->Position );
					AddControl( OneCurrent->Parent, ListBox);
				}
				break;case TYPE_COMBOBOX:
				{
					CComboBox* ComboBox = Shablon->ShablonComboBox[OneCurrent->TipShablon];
					ComboBox = new CComboBox( *( ComboBox ) );
					ComboBox->SetName( OneCurrent->Name );
					ComboBox->SetPosition( OneCurrent->Position );
					AddControl( OneCurrent->Parent, ComboBox);
				}
				break;case TYPE_BUTTON:
				{
					CButton* Button = Shablon->ShablonButton[OneCurrent->TipShablon];
					Button = new CButton( *( Button ) );
					Button->SetName( OneCurrent->Name );
					Button->SetPosition( OneCurrent->Position );
					AddControl( OneCurrent->Parent, Button);
				}
				break;case TYPE_CHECKBOX:
				{
					CCheckBox* CheckBox = Shablon->ShablonCheckBox[OneCurrent->TipShablon];
					CheckBox = new CCheckBox( *( CheckBox ) );
					CheckBox->SetName( OneCurrent->Name );
					CheckBox->SetPosition( OneCurrent->Position );
					AddControl( OneCurrent->Parent, CheckBox);
				}
				break;case TYPE_RADIOBUTTON:
				{
					CRadioButton* RadioButton = Shablon->ShablonRadioButton[OneCurrent->TipShablon];
					RadioButton = new CRadioButton( *( RadioButton ) );
					RadioButton->SetName( OneCurrent->Name );
					RadioButton->SetPosition( OneCurrent->Position );
					AddControl( OneCurrent->Parent, RadioButton);
				}
				break;case TYPE_PROGRESSBAR:
				{
					CProgressBar* ProgressBar = Shablon->ShablonProgressBar[OneCurrent->TipShablon];
					ProgressBar = new CProgressBar( *( ProgressBar ) );
					ProgressBar->SetName( OneCurrent->Name );
					ProgressBar->SetPosition( OneCurrent->Position );
					AddControl( OneCurrent->Parent, ProgressBar);
				}
				break;case TYPE_TRACKBAR:
				{
					CTrackBar* TrackBar = Shablon->ShablonTrackBar[OneCurrent->TipShablon];
					TrackBar = new CTrackBar( *( TrackBar ) );
					TrackBar->SetName( OneCurrent->Name );
					TrackBar->SetPosition( OneCurrent->Position );
					AddControl( OneCurrent->Parent, TrackBar);
				}
				break;case TYPE_PANEL:
				{
					CPanel* Panel = Shablon->ShablonPanel[OneCurrent->TipShablon];
					Panel = new CPanel( *( Panel ) );
					Panel->SetName( OneCurrent->Name );
					Panel->SetPosition( OneCurrent->Position );
					AddControl( OneCurrent->Parent, Panel);
				}
				break;case TYPE_INVENTAR:
				{
					CInventar* Inventar = Shablon->ShablonInventar[OneCurrent->TipShablon];
					Inventar = new CInventar( *( Inventar ) );
					Inventar->SetName( OneCurrent->Name );
					Inventar->SetPosition( OneCurrent->Position );
					AddControl( OneCurrent->Parent, Inventar);
				}
				break;default:
				{
					return false;
				}
			}
		}
	}
	return true;
}
//--------------------------------------------------------------------------------
CNodeTree* CManagerGUI::FindControl(std::string name)
{
	int position = 0;
	while (ListNameControl[position].node != NULL)
	{
		if (name == ListNameControl[position].name)
		{
			return ListNameControl[position].node;
		}
		position++;
	}
	return NULL;
}
//--------------------------------------------------------------------------------
bool CManagerGUI::AddControl(std::string name, CGuiBase* data)
{
	bool Res;
	if (name == "")
		OwnerIterator->TreeIterator.current = NULL;
	else
		OwnerIterator->TreeIterator.current = FindControl(name);
	Res = OwnerIterator->TreeIterator.CheckCollision(data);
	if (Res == false)
		return false;
	Res = OwnerIterator->TreeIterator.AddNode(data);
	if (Res == true)
	{
		ListNameControl[LastPositionList].name = data->GetName();
		ListNameControl[LastPositionList].node = OwnerIterator->TreeIterator.current;
		LastPositionList++;
	}
	else
		return false;
	return true;
}
//--------------------------------------------------------------------------------
bool CManagerGUI::DelControl(std::string name)
{
	CNodeTree* TempNode = FindControl(name);
	if (TempNode != NULL)
		OwnerIterator->TreeIterator.DelNode(TempNode,true);
	else
		return false;
	return true;
}
//--------------------------------------------------------------------------------
bool CManagerGUI::MoveControl(std::string namefrom, std::string nameto)
{
	return true;
}
//--------------------------------------------------------------------------------
vector<GUI_ELEMENT*> CManagerGUI::Draw()
{
	vector<GUI_ELEMENT*> ParamDraw;
	GUI_ELEMENT* PDTemp;
	CTreeIterator* Iter = OwnerIterator->GetIterator();
	Iter->current = Iter->first;
	while (Iter->current != NULL)
	{
		PDTemp = Iter->current->data->onDraw();
		if (PDTemp != NULL)
			ParamDraw.push_back(PDTemp);
		Iter->current = Iter->Next();
	}
	OwnerIterator->FreeIterator(Iter);
	return ParamDraw;
}
//--------------------------------------------------------------------------------
bool CManagerGUI::EventMouse(USHORT KeyMouse, glm::vec2 MouseXY)
{
	CTreeIterator* Iter = OwnerIterator->GetIterator();
	Iter->current = Iter->first;
	CNodeTree* TempCurrentFocusMouse = NULL;

	TempCurrentFocusMouse = CurrentFocusMouse;
	CurrentFocusMouse = Iter->NextXY(MouseXY);

	if (CurrentFocusMouse != NULL)
	{
		if (TempCurrentFocusMouse != NULL)
		{
			if (TempCurrentFocusMouse == CurrentFocusMouse)
			{
				switch (KeyMouse)
				{
					break;case MOUSE_KEY_DOWN:
					{
						CurrentFocusMouse->data->SetCheckMouse(CM_MOUSEDOWN);
						CurrentFocusMouse->data->onMouseDown();
						return true;
					}
					break;default:
					{
						if (CurrentFocusMouse->data->GetCheckMouse() == CM_MOUSEDOWN)
						{
							CurrentFocus = CurrentFocusMouse;
							CurrentFocusMouse->data->SetCheckMouse(CM_MOUSEMOVE);
							CurrentFocusMouse->data->onMouseUp();
							CurrentFocusMouse->data->onMouseMove();
							CurrentFocusMouse->data->onClick();
							return true;
						}
					}
					break;
				}
			}
			else
			{
				TempCurrentFocusMouse->data->SetCheckMouse(CM_FALSE);
				switch (KeyMouse)
				{
					break;case MOUSE_KEY_DOWN:
					{
						CurrentFocusMouse = TempCurrentFocusMouse;
						return true;
					}
					break;default:
					{

					}
					break;
				}
			}
		}
		else
		{
			switch (KeyMouse)
			{
				break;case MOUSE_KEY_DOWN:
				{
					CurrentFocusMouse = NULL;
					return true;
				}
				break;default:
				{

				}
				break;
			}
		}
		CurrentFocusMouse->data->SetCheckMouse(CM_MOUSEMOVE);
		CurrentFocusMouse->data->onMouseMove();
	}
	else if (TempCurrentFocusMouse != NULL)
	{
		TempCurrentFocusMouse->data->SetCheckMouse(CM_FALSE);
		switch (KeyMouse)
		{
			break;case MOUSE_KEY_DOWN:
			{
				CurrentFocusMouse = TempCurrentFocusMouse;
				return true;
			}
			break;default:
			{

			}
			break;
		}
	}

	return true;
}
//--------------------------------------------------------------------------------
bool CManagerGUI::SetControlParam(std::string name, EParam param, void* value)
{
	CNodeTree* Control;
	Control = FindControl(name);
	if (Control != NULL)
	{
		switch (param)
		{
			break;case PARAM_VISIBLE:		Control->data->SetVisible		((bool) value);
			break;case PARAM_ENABLE:		Control->data->SetEnable		((bool) value);
			break;case PARAM_NAME:			Control->data->SetName			((std::string&) value);
			break;case PARAM_POSITION:		Control->data->SetPosition		((glm::vec2&) value);
			break;case PARAM_CURSOR:		Control->data->SetCursor		((std::string&) value);
			break;case PARAM_TEXT:			Control->data->SetText			((std::string&) value);
			break;case PARAM_ITEMS:			Control->data->SetItems			((std::string&) value);
			break;case PARAM_ITEMINDEX:		Control->data->SetItemIndex		((int) value);
			break;case PARAM_CHECKED:		Control->data->SetChecked		((bool) value);
			break;case PARAM_GROUP:			Control->data->SetGroup			((int) value);
			break;case PARAM_MIN:			Control->data->SetMin			((int) value);
			break;case PARAM_MAX:			Control->data->SetMax			((int) value);
			break;case PARAM_VALUE:			Control->data->SetValue			((int) value);
			break;case PARAM_SCROLLBARS:	Control->data->SetScrollBars	((bool) value);
			break;default:					return false;
		}
	}
	else
		return false;
	return true;
}
//--------------------------------------------------------------------------------
bool CManagerGUI::GetControlParam(std::string name, EParam param)
{
	bool Result = false;
	CNodeTree* Control;
	Control = FindControl(name);
	if (Control != NULL)
	{
		switch (param)
		{
			break;case PARAM_VISIBLE:		Result = Control->data->GetVisible();
			break;case PARAM_ENABLE:		Result = Control->data->GetEnable();
			break;case PARAM_NAME:			Control->data->GetName();
			break;case PARAM_POSITION:		Control->data->GetPosition();
			break;case PARAM_SIZE:			Control->data->GetSize();
			break;case PARAM_CURSOR:		Control->data->GetCursor();
			break;case PARAM_TEXT:			Control->data->GetText();
			break;case PARAM_ITEMS:			Control->data->GetItems();
			break;case PARAM_ITEMINDEX:		Control->data->GetItemIndex();
			break;case PARAM_CHECKED:		Result = Control->data->GetChecked();
			break;case PARAM_GROUP:			Control->data->GetGroup();
			break;case PARAM_MIN:			Control->data->GetMin();
			break;case PARAM_MAX:			Control->data->GetMax();
			break;case PARAM_VALUE:			Control->data->GetValue();
			break;case PARAM_SCROLLBARS:	Control->data->GetScrollBars();
			break;default:					return false;
		}
	}

	return Result;
}
//--------------------------------------------------------------------------------
